<template>
  <div class="icon-body">
    <div class="icon-list df aic">
      <div
        v-for="(item, index) in iconList"
        :key="index"
        class="df aic"
        @click="selectedIcon(item.font_class)"
      >
        <i class="iconfont" :class="`icon-${item.font_class}`"></i>
        <span>{{ item.name }}</span>
      </div>
    </div>
  </div>
</template>

<script lang="ts" setup>
import jsonList from '../../../../../public/font/iconfont.json'
const emit = defineEmits(['selected'])
const iconList = ref<any[]>([])
iconList.value = jsonList.glyphs
const selectedIcon = (name: any) => {
  emit('selected', 'icon-' + name)
}
</script>

<style lang="scss" scoped>
.icon-body {
  width: 100%;
  padding: 10px;
  .icon-list {
    height: 200px;
    overflow-y: scroll;
    flex-wrap: wrap;
    div {
      height: 30px;
      line-height: 30px;
      cursor: pointer;
      width: 50%;
    }
    .iconfont {
      margin-right: 6px;
    }
  }
}
</style>
